import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker_plus/flutter_datetime_picker_plus.dart';
import 'package:get/get.dart';
import 'package:xin_he/page/mine/xin_he_mine_withdraw/xin_he_mine_withdraw_records/xin_he_withdraw_model_entity.dart';

import '../../../../utils/xh_styles.dart';
import '../../../../utils/xin_he_UI_constancs.dart';
import '../../../../utils/xin_he_image.dart';
import '../../xin_he_mine_cloud_cha_zi/xin_he_assets_account_list_item_entity.dart';
import 'xin_he_mine_withdraw_records_logic.dart';

class XinHeMineWithdrawRecordsPage extends StatelessWidget {
  XinHeMineWithdrawRecordsPage({Key? key}) : super(key: key);

  final logic = Get.put(XinHeMineWithdrawRecordsLogic());
  final state = Get.find<XinHeMineWithdrawRecordsLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Obx(() => Scaffold(
      appBar: AppBar(
        leading: IconButton(
            onPressed: (){
              Get.back();
            },
            icon: Container(
              padding: const EdgeInsets.only(left: 7),
              alignment: Alignment.centerLeft,
              child: const XinHeAssetImage(
                'assets/images/home/app_back_3.png',
                width: 9.5,
                height: 17,
                fit: BoxFit.cover,),
            )
        ),
        backgroundColor: Colors.white,
        shadowColor: Colors.transparent,
        title: Text('提现记录',style: TextStyle(color:XinHeColor('#222222'),fontSize: 17,fontWeight: FontWeight.w600)),
        centerTitle: true,
      ),
      body: Column(children: [
        Container(
          alignment: Alignment.centerLeft,
          height: 37,
          child: Row(children: [
            const SizedBox(width: 15,),
            GestureDetector(
                onTap: (){
                  DatePicker.showDatePicker(
                      context,
                      showTitleActions: true,
                      minTime: DateTime(2024,1),
                      maxTime: DateTime(2026,1),
                      onChanged: (date){
                        print('change $date');
                        state.currentDate.value = logic.getYearMonth(date);


                      },
                      currentTime: DateTime.now(),
                      locale: LocaleType.zh

                  );
                },
                child: Text(state.currentDate.value,style: TextStyle(color: XinHeColor('#333333'),fontSize: 14,fontWeight: FontWeight.bold),))
          ],),
        ),
        Expanded(child: ListView.separated(
          itemCount: logic.dataList.length,
          itemBuilder: (ctx,index){
            XinHeWithdrawModelEntity model = logic.dataList[index];
            return _itemView(model);
          }, separatorBuilder: (BuildContext context, int index) { return SizedBox(height: 10,); },))

      ],),

    ));
  }


  Widget _itemView(XinHeWithdrawModelEntity model){
    return Container(
      margin: const EdgeInsets.symmetric(horizontal: 15),
      height: 66,
      padding: const EdgeInsets.symmetric(horizontal: 15),
      decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.circular(5)),
      child: Row(children: [
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('提现',style: TextStyle(color: XinHeColor('#333333'),fontSize: 13,fontWeight: FontWeight.w500),),
            SizedBox(height: 10,),
            Text(model.createTime ??'',style: TextStyle(color: XinHeColor('#999999'),fontSize: 11,fontWeight: FontWeight.w500),),



          ],),
        const Spacer(),
        Text('${model.realityAccountFee??0}',style: TextStyle(color: XinHeColor('#EB5029'),fontSize: 13,fontWeight: FontWeight.w500),),
      ],),
    );
  }

}
